import type { RouteRecordRaw } from 'vue-router';
import AdminLayout from '@/views/admin/AdminLayout.vue';

// 管理员路由配置
export const adminRoutes: RouteRecordRaw[] = [
  {
    path: '/admin',
    name: 'Admin',
    component: AdminLayout,
    redirect: '/admin/dashboard',
    meta: {
      title: '系统管理',
      requiresAuth: true,
      permissions: ['admin'],
      isAdmin: true,
    },
    children: [
      {
        path: '/admin/dashboard',
        name: 'AdminDashboard',
        component: () => import('@/views/admin/dashboard/index.vue'),
        meta: {
          title: '管理后台 - 控制台',
          keepAlive: true,
        },
      },
      {
        path: '/admin/system',
        name: 'AdminSystem',
        component: () => import('@/views/admin/system/index.vue'),
        meta: {
          title: '管理后台 - 系统管理',
        },
      },
      {
        path: '/admin/merchants',
        name: 'AdminMerchants',
        component: () => import('@/views/admin/merchants/index.vue'),
        meta: {
          title: '管理后台 - 商户管理',
        },
      },
      {
        path: '/admin/merchants/:merchantId',
        name: 'AdminMerchantDetail',
        component: () => import('@/views/admin/MerchantDetail.vue'),
        meta: {
          title: '管理后台 - 商户详情',
        },
      },
      {
        path: '/admin/merchants/:merchantId/products',
        name: 'AdminMerchantProducts',
        component: () => import('@/views/admin/MerchantProducts.vue'),
        meta: {
          title: '管理后台 - 商户产品管理',
        },
      },
      {
        path: '/admin/products',
        name: 'AdminProducts',
        component: () => import('@/views/admin/products/index.vue'),
        meta: {
          title: '管理后台 - 产品管理',
        },
      },
      {
        path: '/admin/users',
        name: 'UserManagement',
        component: () => import('@/views/admin/Users.vue'),
        meta: {
          title: '用户管理',
          icon: 'users',
        },
      },
      {
        path: '/admin/users/:userId',
        name: 'UserDetail',
        component: () => import('@/views/admin/UserDetail.vue'),
        meta: {
          title: '用户详情',
          hideInMenu: true,
        },
      },
      {
        path: '/admin/orders',
        name: 'AdminOrders',
        component: () => import('@/views/admin/orders/index.vue'),
        meta: {
          title: '管理后台 - 订单管理',
        },
      },
      {
        path: '/admin/finance',
        name: 'AdminFinance',
        component: () => import('@/views/admin/finance/index.vue'),
        meta: {
          title: '管理后台 - 财务管理',
        },
        redirect: '/admin/finance/withdrawals',
        children: [
          {
            path: 'withdrawals',
            name: 'AdminWithdrawals',
            component: () => import('@/views/admin/finance/Withdrawals.vue'),
            meta: {
              title: '管理后台 - 提现审核',
            },
          },
          {
            path: '/admin/transactions',
            name: 'AdminTransactions',
            component: () => import('@/views/admin/finance/Transactions.vue'),
            meta: {
              title: '管理后台 - 交易记录',
            },
          },
          {
            path: '/admin/withdrawalFees',
            name: 'AdminswithdrawalFees',
            component: () => import('@/views/admin/finance/withdrawalFees.vue'),
            meta: {
              title: '管理后台 - 手续费设置',
            },
          },
        ],
      },
      {
        path: '/admin/banner',
        name: 'AdminBanner',
        component: () => import('@/views/admin/banner/index.vue'),
        meta: {
          title: '管理后台 - 订单管理',
        },
      },
      {
        path: '/admin/fans',
        name: 'AdminFans',
        component: () => import('@/views/admin/banner/fans.vue'),
        meta: {
          title: '管理后台 - 订单管理',
        },
      },
      {
        path: '/admin/content',
        name: 'AdminContent',
        component: () => import('@/views/admin/content/index.vue'),
        meta: {
          title: '管理后台 - 内容管理',
        },
      },
      {
        path: '/admin/analytics',
        name: 'AdminAnalytics',
        component: () => import('@/views/admin/analytics/index.vue'),
        meta: {
          title: '管理后台 - 数据分析',
        },
      },
      {
        path: '/admin/demo',
        name: 'AdminDemo',
        component: () => import('@/views/admin/demo/index.vue'),
        meta: {
          title: '管理后台 - 组件演示',
        },
      },
    ],
  },
];

export default adminRoutes;
